
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

#include "arduinomega/Servo/Servo.h"
#include "arduinomega/HardwareSerial.h"
#include "arduinomega/WProgram.h"

extern "C" void __cxa_pure_virtual(){}

#define SERVO 9
#define SERVO_DELAY 15

Servo myservo;  // create servo object to control a servo

void loop()
{
	int i;

	for( i=0; i<180; i++ )
	{
		myservo.write( i );                  // sets the servo position according to the scaled value
		delay( SERVO_DELAY );                           // waits for the servo to get there
	}
	for( i=179; i<=0; i++ )
	{
		myservo.write( i );                  // sets the servo position according to the scaled value
		delay( SERVO_DELAY );                           // waits for the servo to get there
	}
}

int main(){

	init();
	myservo.attach( SERVO );
	Serial.begin( BAUD_RATE );
	while( true )
	{
		loop();
	}

	return 1;
}
